package com.xingzuo.library_expert.ui.fragment;

import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ViewFlipper;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseMvpFragment;
import com.xingzuo.library_expert.R;
import com.xingzuo.library_expert.R2;
import com.xingzuo.library_expert.adapter.ExpertAdapter;
import com.xingzuo.library_expert.bean.ExpertBean;
import com.xingzuo.library_expert.contract.ExpertContract;
import com.xingzuo.library_expert.presenter.ExpertPresenter;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = AppActivityKey.EXPERTFRAGMENT)
public class ExpertFragment extends BaseMvpFragment<ExpertPresenter> implements ExpertContract.View {
    @BindView(R2.id.tv_title)
    TextView tvTitle;
    @BindView(R2.id.fl_serch)
    FrameLayout flSerch;
    @BindView(R2.id.ll_caidan)
    LinearLayout llCaidan;
    @BindView(R2.id.vf_home_new)
    ViewFlipper vfHomeNew;
    @BindView(R2.id.ll_paomadeng)
    LinearLayout llPaomadeng;
    @BindView(R2.id.rv_list)
    RecyclerView rvList;
    private ExpertAdapter adapter;
    private List<ExpertBean> expertBeans=new ArrayList<>();
    @Override
    public ExpertPresenter getPresenter() {
        return new ExpertPresenter();
    }

    @Override
    public int getViewId() {
        return R.layout.fragment_expert;
    }

    @Override
    public void initView() {
        expertBeans.add(new ExpertBean());
        expertBeans.add(new ExpertBean());
        expertBeans.add(new ExpertBean());
        expertBeans.add(new ExpertBean());
        expertBeans.add(new ExpertBean());
        adapter=new ExpertAdapter(R.layout.itme_expert_list,expertBeans);
        rvList.setLayoutManager(new LinearLayoutManager(mContext));
        rvList.setAdapter(adapter);
        for (int i=0;i<10;i++){
            View view = View.inflate(mContext, R.layout.item_expert_lunbo, null);
            TextView textView=view.findViewById(R.id.tv_title);
            textView.setText("我是"+i+"号");
            view.setTag(i);
            vfHomeNew.addView(view);
        }
    }

    @Override
    public void initLinsenterner() {
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                startIntent(AppActivityKey.EXPERTDETAILACTIVITY);
            }
        });
    }

    @Override
    public void getData() {


    }

    @OnClick(R2.id.fl_serch)
    public void onViewClicked() {

    }
}